﻿@namespace SE.PO.CInterface.Web.Pages.DB.Signal
@page "/db/signals"
@using SE.PO.CInterface.Web.Clients
@using SE.PO.CInterface.DBProtocols.Signals
@using SE.PO.CInterface.Web.Pages.DB.Components
@using AutoMapper
@inject SignalClient Client
@inject INotificationService Notice
@inject IMapper Mapper
<PageContainer Title="信号数据">
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>首页</BreadcrumbItem>
            <BreadcrumbItem>数据库协议</BreadcrumbItem>
            <BreadcrumbItem>信号数据</BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <Content>
        <span>下级SC把监控对象配置根据“数据库接口定义”的数据结构存储到中间数据库表中，增加、修改和删除任何配置，下级SC必须保证能够及时的维护该中间数据库表中的数据。涉及到的中间数据库表有M_Area、M_Site、M_Signal、M_Signal、M_SIGNAL，M_Signal，NodeModify，NodeUpdate。中间数据库表中的数据除了NodeUpdate外均由下级SC维护，下级SC保证上述表中的数据和下级SC的配置一致；NodeUpdate表由上级SC负责添加数据，下级SC定时获取数据并维护（删除）。</span>
    </Content>
    <ChildContent>
        <Card>
            <Row Gutter="24">
                
                <GridCol Span="24">
                    <Button OnClick="@SyncSignals" Type="primary" Style="margin-bottom:16px">
                        同步信号数据
                    </Button>
                    @* <Button OnClick="@(() => { _addVisible = true; })" Style="margin-bottom:16px"> *@
                    @*     新增设备 *@
                    @* </Button> *@
                    <Button OnClick="@DeleteSelectedRows" Type="danger" Style="margin-bottom:16px">
                        删除选定
                    </Button>
                    <Table @ref="_table"
                           TItem="SignalDto"
                           ScrollY="900px"
                           Loading="@_loadingData"
                           DataSource="@_source"
                           Total="_total"
                           @bind-PageIndex="_pageIndex"
                           @bind-PageSize="_pageSize"
                           @bind-SelectedRows="_selectedRows"
                           OnChange="OnChange"
                           Size="TableSize.Small">

                        <ColumnDefinitions>
                            <Selection Key="@(context.Id)"/>
                            @* <PropertyColumn Title="下级SCID" Property="c => c.ScId"/> *@
                            @* <PropertyColumn Title="站点" Property="c => c.SiteSiteName"/> *@
                            <PropertyColumn Width="240" Title="设备名称" Property="c => c.DeviceEquipment"/>
                            @* <PropertyColumn Title="数据类型" Property="c => c.Type"/> *@
                            <PropertyColumn Width="300" Title="监控数据标识号" Property="c => c.Id"/>

                            <PropertyColumn Width="240" Title="信号名称" Property="c => c.SignalName"/>
                            <PropertyColumn Title="告警等级" Property="c => c.AlarmLevelDisplayName"/>
                            @* <PropertyColumn Title="存储周期" Property="c => c.StoragePeriod"/> *@
                            @* <PropertyColumn Title="绝对阈值" Property="c => c.AbsoluteVal"/> *@
                            @* <PropertyColumn Title="百分比阈值" Property="c => c.RelativeVal"/> *@
                            @* <PropertyColumn Title="上限" Property="c => c.HLimit"/> *@
                            @* <PropertyColumn Title="过高上限" Property="c => c.SHLimit"/> *@
                            @* <PropertyColumn Title="下限" Property="c => c.LLimit"/> *@
                            @* <PropertyColumn Title="过低上限" Property="c => c.SLimit"/> *@
                            <PropertyColumn Title="描述信息" Property="c => c.Describe"/>
                            <ActionColumn Width="160" Title="操作" Fixed="right">
                                <Space>
                                    <SpaceItem>
                                        <Button Danger OnClick="@(() => { _delVisible = true; Delete(context.Id);})">删 除</Button>
                                    </SpaceItem>
                                    <SpaceItem>
                                        <Button OnClick="@(() => { _editVisible = true; Edit(context.Id);})">修 改</Button>
                                    </SpaceItem>
                                </Space>
                            </ActionColumn>
                        </ColumnDefinitions>
                        @* <ExpandTemplate> *@
                        @* 		 <Form  *@
                        @*                   LabelColSpan="8" *@
                        @*                   WrapperColSpan="16"> *@
                        @*                 <FormItem Label="存储周期"> *@
                        @*                     <Input @bind-Value="@context.StoragePeriod" /> *@
                        @*                 </FormItem> *@
                        @*                 <FormItem Label="绝对阈值"> *@
                        @*                     <InputPassword @bind-Value="@context.AbsoluteVal" /> *@
                        @*                 </FormItem> *@
                        @*                *@
                        @*                  *@
                        @*             </Form> *@
                        @* 	</ExpandTemplate> *@
                    </Table>
                </GridCol>
            </Row>

        </Card>
    </ChildContent>
</PageContainer>

<Modal Title="新增信号"
       Centered="true"
       Width="1024"
       Visible="@_addVisible"
       OnOk="@AddHandleOk"
       OnCancel="@AddHandleCancel">
    <AddSignalFrom @ref="_addFrom"
                   OnSuccess="async () => { _addVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                   OnFailure="() => { _addVisible = true; }"
                   OnCancel="() => { _addVisible = true; }">
    </AddSignalFrom>
</Modal>

<Modal Title="同步信号"
       Centered="true"
       Visible="@_syncVisible"
       Width="1440"
       MaxBodyHeight="@("80vh")"
       OnOk="@SyncHandleOk"
       OnCancel="@SyncHandleCancel"
       ConfirmLoading="@_confirmLoading">
    <SyncSignalFrom @ref="_syncFrom"

                    OnSuccess="async () => { _syncVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                    OnFailure="() => { _syncVisible = true; }"
                    OnCancel="() => { _syncVisible = true; }">
    </SyncSignalFrom>
</Modal>

<Modal Title="编辑信号"
       Centered="true"
       Width="1024"
       Visible="@_editVisible"
       OnOk="@EditHandleOk"
       OnCancel="@EditHandleCancel">
    <EditSignalFrom @ref="_editFrom"
                    Model="@_editModel"
                    OnSuccess="async () => { _editVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                    OnFailure="() => { _editVisible = true; }"
                    OnCancel="() => { _editVisible = true; }">
    </EditSignalFrom>
</Modal>

<Modal Title="删除信号"
       Centered="true"
       Visible="@_delVisible"
       OnOk="@DeleteHandleOk"
       OnCancel="@DeleteHandleCancel">
    <DelSignalFrom @ref="_delFrom"
                   Model="DelModel"
                   Models="@DelModels"
                   OnSuccess="async () => { _delVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                   OnFailure="() => { _delVisible = true; }"
                   OnCancel="() => { _delVisible = true; }">
    </DelSignalFrom>
</Modal>